package flib;

import java.util.Vector;

import simpleGeom.HasPos2D;
import simpleGeom.Vec2D;

public class PolyLine {
Vector<HasPos2D> pts;
public float getLength(){
	float sumL=0;
	for (int i=0;i<pts.size()-1;i++){
		HasPos2D p1=pts.get(i);
		HasPos2D p2=pts.get(i+1);
		sumL+=Vec2D.dist(p1, p2);
	}
	return sumL;
}
public float getLengthFromP(HasPos2D p){
	float sumL=0;
	for (int i=0;i<pts.size()-1;i++){
		HasPos2D p1=pts.get(i);
		HasPos2D p2=pts.get(i+1);
		sumL+=Vec2D.dist(p1, p2);
		if (p2==p)return sumL;
	}
	return sumL;
}
}
